//index.js
//获取应用实例
const app = getApp()
const Api = require("../../utils/api.js").API
// const Store = require("../../utils/store.js").store
// const codeZ = require("../../utils/util.js")
Page({
    data: {
       list:[],
    },
    onLoad(option) {
        var a = JSON.parse(option.item);
      if(a.length >0){
          a.forEach(item=>{
              item.isCheak = true
          })
      }
      this.setData({
          list:a
      })
        console.log(a);
       
    },
    onShow: function() {
      
     
    },
    clickDe: function(e) {
    
        
        let i = e.currentTarget.dataset.index;
        var comSta = `list[${i}].isCheak`;
        let a = this.data.list[i].isCheak;
        if (a == true) {
            this.setData({
                [comSta]: false
            })
        } else {
            this.setData({
                [comSta]: true
            })
        }
        console.log(this.data.list);
        // wx.navigateTo({
        //     url: '../shouDaoDetail/index',
        // })
    },
    zhifu:function(){
        var arr =  this.data.list.concat();
        arr.forEach((item,i)=>{
            if(item.isCheak == false){
                arr.splice(i,1);
            }
        })
        Api.saveBatchApi(arr).then(res=>{
           if(res.code == 0){
               wx.navigateBack();
           }
        })
    }
   
    
   
   

  
    

});
